package com.freecloud.spring.lifecycle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * @Author: maomao
 * @Date: 2021-04-19 14:24
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    public MyBeanFactoryPostProcessor() {
        super();
        System.out.println("【构造方法】MyBeanFactoryPostProcessor！！");
    }


    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        System.out.println("【MyBeanFactoryPostProcessor接口】postProcessBeanFactory！！");

        BeanDefinition bd = configurableListableBeanFactory.getBeanDefinition("user");
        bd.getPropertyValues().addPropertyValue("age", "30");
    }
}
